function PullPushSel(o) {
    this.vsppDiv = o;
    this.vsppDivId = jQuery(o).attr("id");
}
;

PullPushSel.prototype.onReady = function() {
    var $vsppDiv = jQuery(this.vsppDiv);
    var tempVsppDivId = this.vsppDivId;
    //移到右边
    $vsppDiv.find("#" + tempVsppDivId + "vsselpush").click(function() {
        $vsppDiv.find('#' + tempVsppDivId + 'pullDiv>select option:selected').appendTo('#' + tempVsppDivId + 'pushDiv>select');
    });
    //移到左边
    $vsppDiv.find("#" + tempVsppDivId + "vsselpull").click(function() {
        $vsppDiv.find('#' + tempVsppDivId + 'pushDiv>select option:selected').appendTo('#' + tempVsppDivId + 'pullDiv>select');
    });

    //全部移到右边
    $vsppDiv.find("#" + tempVsppDivId + "vsselpushall").click(function() {
        //获取全部的选项,删除并追加给对方
        $vsppDiv.find('#' + tempVsppDivId + 'pullDiv>select option').appendTo('#' + tempVsppDivId + 'pushDiv>select');
    });
    //全部移到左边
    $vsppDiv.find("#" + tempVsppDivId + "vsselpullall").click(function() {
        $vsppDiv.find('#' + tempVsppDivId + 'pushDiv>select option').appendTo('#' + tempVsppDivId + 'pullDiv>select');
    });
    //双击选项
    $vsppDiv.find("#" + tempVsppDivId + "pullDiv>select").dblclick(function() { //绑定双击事件
        //获取全部的选项,删除并追加给对方
        $vsppDiv.find("option:selected", this).appendTo('#' + tempVsppDivId + 'pushDiv>select'); //追加给对方
    });

    //可以移动里面的选项调整顺序
    $vsppDiv.find("#" + tempVsppDivId + "pullDiv>select").bind('keydown', function(e) { //
        if ($(this).focus()) {
            switch (e.keyCode) {
                case 37:
                    var $selected = $vsppDiv.find("#" + tempVsppDivId + "pullDiv>select").find("option:selected", this);
                    $selected.each(function() {
                        var $prev = $(this).prev();
                        $(this).after($prev);
                    });
                    break;
                case 39:
                    var $selected = $vsppDiv.find("#" + tempVsppDivId + "pullDiv>select").find("option:selected", this);
                    $selected.sort();
                    $selected.each(function() {
                        var $next = $(this).next();
                        $next.after($(this));
                    });

                    break;
            }
        }

    });
    $vsppDiv.find("#" + tempVsppDivId + "pushDiv>select").bind('keydown', function(e) { //
        if ($(this).focus()) {
            switch (e.keyCode) {
                case 37:
                    var $selected = $vsppDiv.find("#" + tempVsppDivId + "pushDiv>select").find("option:selected", this);
                    $selected.each(function() {
                        var $prev = $(this).prev();
                        $(this).after($prev);
                    });
                    break;
                case 39:
                    var $selected = $vsppDiv.find("#" + tempVsppDivId + "pushDiv>select").find("option:selected", this);
                    $selected.sort();
                    $selected.each(function() {
                        var $next = $(this).next();
                        $next.after($(this));
                    });

                    break;
            }
        }

    });
    //双击选项
    $vsppDiv.find("#" + tempVsppDivId + "pushDiv>select").dblclick(function() {
        $vsppDiv.find("option:selected", this).appendTo('#' + tempVsppDivId + 'pullDiv>select');
    });
    //确定中间的4个图片在select的中间显示
    var d1Height = jQuery('#' + tempVsppDivId + 'pullDiv').height();
    var d2Height = jQuery('#' + tempVsppDivId + 'middleIcons').height();
    $vsppDiv.find('#' + tempVsppDivId + 'middleIcons').css('margin-top', (d1Height - d2Height) / 2);
};

//全选左边select里面的值
PullPushSel.prototype.checkLeftAll = function() {
    jQuery('#' + this.vsppDivId + 'pullDiv>select option').each(function() {
        $(this).attr('selected', true);
    });
};

//全选右边select里面的值
PullPushSel.prototype.checkRightAll = function() {
    jQuery('#' + this.vsppDivId + 'pushDiv>select option').each(function() {
        $(this).attr('selected', true);
    });
};

//获得左边select
PullPushSel.prototype.getLeftSelect = function() {
    return jQuery('#' + this.vsppDivId + 'pullDiv>select');
};

//获得右边select
PullPushSel.prototype.getRightSelect = function() {
    return jQuery('#' + this.vsppDivId + 'pushDiv>select');
};

//获得左边select值
PullPushSel.prototype.getLeftSelectValue = function() {
	var valueStr = "";
	var options = jQuery('#' + this.vsppDivId + 'pullDiv>select option');
    options.each(function(i){
    	if(i == options.length - 1)
    		valueStr += $(this).val();
    	else
    		valueStr += ($(this).val() + ",");
    });
    return valueStr;
};

//获得右边select值
PullPushSel.prototype.getRightSelectValue = function() {
	var valueStr = "";
	var options = jQuery('#' + this.vsppDivId + 'pushDiv>select option');
    options.each(function(i){
    	if(i == options.length - 1)
    		valueStr += $(this).val();
    	else
    		valueStr += ($(this).val() + ",");
    });
    return valueStr;
};

//获得左边显示值
PullPushSel.prototype.getLeftSelectText = function() {
	var valueStr = "";
	var options = jQuery('#' + this.vsppDivId + 'pullDiv>select option');
    options.each(function(i){
    	if(i == options.length - 1)
    		valueStr += $(this).text();
    	else
    		valueStr += ($(this).text() + ",");
    });
    return valueStr;
};

//获得右边显示值
PullPushSel.prototype.getRightSelectText = function() {
	var valueStr = "";
	var options = jQuery('#' + this.vsppDivId + 'pushDiv>select option');
    options.each(function(i){
    	if(i == options.length - 1)
    		valueStr += $(this).text();
    	else
    		valueStr += ($(this).text() + ",");
    });
    return valueStr;
};
